package com.study.system.controller;

import com.study.system.dto.ResultData;
import com.study.system.entity.AddClubLog;
import com.study.system.entity.Post;
import com.study.system.service.PostService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;


@RestController
@RequestMapping("/post")
public class PostController {

    @Resource
    private PostService postService;

    /**
     * 获取所有职位信息
     *
     * @return 职位名称列表
     */
    @GetMapping("/get_post_names")
    public ResultData<List<Post>> getPostNames() {
        List<Post> postNames = postService.getPostNames();
        return ResultData.success(postNames);
    }

    /**
     * 修改用户职位
     *
     * @param logInfo 日志信息
     * @return 修改结果
     */
    @PostMapping("/modify_post")
    public ResultData<Boolean> modifyUserPost(@RequestBody AddClubLog logInfo) {
        return ResultData.success(postService.modifyUserPost(logInfo.getUserId(), logInfo.getClubId(), logInfo.getPostId()));
    }

}
